package com.varian.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.varian.log.annotation.ApiLog;
import com.varian.service.annotation.Resubmit;
import com.varian.service.web.BaseController;
import com.varian.system.dto.SysTaskPageDTO;
import com.varian.system.service.ISysTaskService;
import com.varian.system.vo.SysTaskVO;
import com.varian.tool.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ben
 * @since 2024/12/27
 */
@Resubmit
@RestController
@Tag(name = "任务控制层")
@RequestMapping("/task")
public class SysTaskController extends BaseController<ISysTaskService> {

    @ApiLog
    @GetMapping("page")
    @Operation(summary = "任务分页查询")
    @PreAuthorize("hasAuthority('task:page')")
    public R<Page<SysTaskVO>> page(@Validated SysTaskPageDTO dto){
        return R.data(baseService.page(dto));
    }

    @ApiLog
    @GetMapping("{id:\\d+}")
    @Operation(summary = "任务详情")
    @PreAuthorize("hasAuthority('task:detail')")
    public R<SysTaskVO> detail(@PathVariable("id") Long id){
        return R.data(baseService.detail(id));
    }

}
